<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
<head th:replace="admin/_fragments :: head(~{::title})">
    <meta charset="UTF-8">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/semantic-ui/2.2.4/semantic.min.css">
    <link rel="stylesheet" href="../../static/css/lk.css"/>
    <link rel="stylesheet" href="../../static/lib/editormd/css/editormd.css" th:href="@{/lib/editormd/css/editormd.css}">
    <title>博客新增</title>
</head>
<body>
<!--导航-->
<nav th:replace="admin/_fragments :: menu(1)" class="ui inverted attached segment lk-padded-tb-mini">
    <div class="ui container">
<!--        stackable可堆叠的-->
        <div class="ui inverted stackable secondary menu">
            <h2 class="ui teal header item">管理后台</h2>
            <a href="#" class="item lk-item lk-mobile-hide"><i class=" home icon"></i> 博客</a>
            <a href="#" class="item lk-item lk-mobile-hide"><i class=" idea icon"></i> 分类</a>
            <a href="#" class="item lk-item lk-mobile-hide"><i class=" tag icon"></i>标签</a>
            <div class="right item lk-item lk-mobile-hide menu">
                <div class="ui dropdown item">
                    <div class="text">
                        <img src="https://picsum.photos/id/1004/100/100" alt="" class="ui avatar image">张三丰
                        <i class="dropdown icon"></i>
                    </div>
                    <div class="menu">
                        <a href="#" class="item">注销</a>
                    </div>
                </div>
            </div>
        </div>
    </div>
<!--    导航小图标-->
    <a href="#" class="ui black icon button lk-right-top lk-mobile-show menu toggle">
        <i class="sidebar icon"></i>
    </a>
</nav>
<div class="ui attached pointing menu">
    <div class="ui container">
        <div class="right  menu">
            <a href="#" th:href="@{/admin/blogs/input}" class=" mini basic teal item">发布</a>
            <a href="#" th:href="@{/admin/blogs}" class=" mini basic teal item">列表</a>
        </div>
    </div>
</div>
<!--中间部分-->
<div class="lk-container-small">
    <div class="ui container">
    <br>
    <br>
    <br>
        <form id="blog-form" action="#" th:object="${blog}" th:action="@{/admin/blogs}" method="post" class="ui form">
            <input type="hidden" name="published" th:value="*{published}">
            <input type="hidden" name="id" th:value="*{id}">
            <div class="required field">
                <div class="ui left labeled input ">
                    <div class="ui selection dropdown">
                        <input type="hidden" value="原创"  th:value="*{flag}">
                        <i class="dropdown icon"></i>
                        <div class="default text">原创</div>
                        <div class="menu">
                            <div class="item" data-value="原创">原创</div>
                            <div class="item" data-value="原创">转载</div>
                            <div class="item" data-value="原创">翻译</div>
                        </div>
                    </div>
                    <input type="text" id="title" name="title" placeholder="标题" th:value="*{title}">
                    <label for="title"></label>
                </div>
            </div>
            <div class=" required field">
                <div id="md-content"  style="z-index:1 !important;">
                <textarea placeholder="博客内容" name="content"  style="display: none" th:text="*{content}">
                这是博客内容
                </textarea>
                </div>
            </div>
            <div class="two fields">
                <div class=" required field">
                    <div class="ui left  labeled input">
                        <label class="ui compact basic teal label " >分类</label>
                        <div class="ui fluid selection dropdown">
                            <input type="hidden" name="type.id" th:value="*{type}!=null ? *{type.id}">
                            <div class="default action text">分类</div>
                            <i class="dropdown icon"></i>
                            <div class="menu">
                                <div th:each="type : ${types}" th:data-value="${type.id}" th:text="${type.name}" class="item" >错误日志</div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="field">
                    <div class="ui left action labeled input">
                        <label class="ui compact basic teal label " >标签</label>
                        <div class="ui fluid selection multiple search dropdown">
                            <input type="hidden" name="tagIds" th:value="*{tagIds}">
                            <div class="default action text">标签</div>
                            <i class="dropdown icon"></i>
                            <div class="menu">
                                <div  th:each="tag : ${tags}" th:data-value="${tag.id}" th:text="${tag.name}" class="item" data-value="1">java</div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class=" required field">
                <div class="ui left labeled input">
                    <label class="ui teal basic label">首图</label>
                    <input type="text" name="firstPicture" th:value="*{firstPicture}" placeholder="首图引用地址">
                </div>
            </div>
            <div class="inline fields">
                <div class="field">
                    <div class="ui checkbox">
                        <input type="checkbox"id="recommend" name="recommend"  th:checked="*{recommend}"  class="hidden" checked>
                        <label for="recommend">推荐</label>
                    </div>
                </div>
                <div class="field">
                    <div class="ui checkbox">
                        <input type="checkbox" id="shareStatement" name="shareStatement"  th:checked="*{shareStatement}" class="hidden">
                        <label for="shareStatement">转载声明</label>
                    </div>
                </div>
                <div class="field">
                    <div class="ui checkbox">
                        <input type="checkbox"id="appreciation" name="appreciation" th:checked="*{appreciation}" class="hidden">
                        <label for="appreciation">赞赏</label>
                    </div>
                </div>
                <div class="field">
                    <div class="ui checkbox">
                        <input type="checkbox" id="commentabled" name="commentabled" th:checked="*{commentabled}" class="hidden">
                        <label for="commentabled">评论</label>
                    </div>
                </div>
            </div>
            <div class="ui error message"></div>
            <div class="ui right aligned container">
                <button  type="button" class="ui button" onclick="window.history.go(-1)">返回</button>
                <button  type="button" class="ui teal button"  id="save-btn">保存</button>
                <button  type="button" class="ui orange button" id="publish-btn">提交</button>
            </div>
        </form>
    <br>
    <br>
    <br>
    <br>

    </div>
    </div>

<!--底部-->
<footer th:replace="admin/_fragments :: footer" class="ui stackable inverted vertical segment ">
<div class="ui stackable center aligned container lk-padded-tb">
    <div class="ui  stackable inverted divided grid">
        <div class="three wide column">
            <img src="../../static/images/这是一个网上的二维码.jpg" alt="二维码图片" style="width: 10em;height: 10em">
        </div>
        <div class="three wide column">
            <h4 class="ui inverted header">最新博客</h4>
            <div class="ui inverted link list">
                <a href="#" class="item">用户故事</a>
                <a href="#" class="item">用户故事</a>
                <a href="#" class="item">用户故事</a>
            </div>
        </div>
        <div class="three wide column">
            <h4 class="ui inverted header">最新博客</h4>
            <div class="ui inverted link list">
                <a href="#" class="item">用户故事</a>
                <a href="#" class="item">用户故事</a>
                <a href="#" class="item">用户故事</a>
            </div>
        </div>
        <div class="seven wide column">
            <h4 class="ui inverted header">最新博客</h4>
            <p>这是我的个人博客</p>
        </div>
    </div>
    <div class="ui inverted section divider">    </div>
    <p class="lk-text-thin lk-text-space lk-opacity-tiny" style="align-content: center"> Copyright © 2020 - 2021 LKBS Designed by LKBS</p>
</div>
</footer>
<!--/*/<th:block th:replace="admin/_fragments :: script">/*/-->
<script src="https://cdn.jsdelivr.net/npm/jquery@3.2.1/dist/jquery.min.js"></script>
<script src="../../static/lib/editormd/editormd.min.js" th:src="@{/lib/editormd/editormd.min.js}"></script>
<script src="https://cdn.jsdelivr.net/semantic-ui/2.2.4/semantic.min.js"></script>
<!--/*/</th:block>/*/-->
<script>
    //Markdown插件初始化
    let MDEditor;

    $(function() {
        MDEditor = editormd( {
            id:"md-content",
            width   : "100%",
            height  : 640,
            syncScrolling : "single",
            // path    : "../static/lib/editormd/lib/"
            path    : "/lib/editormd/lib/"
        });
    });
        $(".menu.toggle").click(function () {
            $(".lk-item").toggleClass('lk-mobile-show');
        })
        //二维码弹窗
        $('#payButton').popup({
            popup: $('.payQR.popup'),
            on: 'click',
            position: 'bottom center'
        });
        //下拉组件初始化
        $('.ui.dropdown').dropdown({
                on: "hover"
            }
        );
        //表单验证
    $('.ui.form').form({
        fields : {
            title : {
                identifier: 'title',
                rules: [{
                    type : 'empty',
                    prompt: '标题：请输入博客标题'
                }]
            },
            content : {
                identifier: 'content',
                rules: [{
                    type : 'empty',
                    prompt: '标题：请输入博客内容'
                }]
            },
            typeId : {
                identifier: 'type.id',
                rules: [{
                    type : 'empty',
                    prompt: '标题：请输入博客分类'
                }]
            },
            firstPicture : {
                identifier: 'firstPicture',
                rules: [{
                    type : 'empty',
                    prompt: '标题：请输入博客首图'
                }]
            },
            description : {
                identifier: 'description',
                rules: [{
                    type : 'empty',
                    prompt: '标题：请输入博客描述'
                }]
            }
        }
    });
    //绑定点击事件
    $('.menu.toggle').click(function () {
        $('.m-item').toggleClass('lk-mobile-hide');
    });

    $('.ui.dropdown').dropdown({
        on : 'hover'
    });

    //博客保存发布按钮 id="blog-form" 表单id属性
    $('#save-btn').click(function () {
        $('[name="published"]').val(false);
        $('#blog-form').submit();
    });


    $('#publish-btn').click(function () {
        $('[name="published"]').val(true);
        $('#blog-form').submit();
    });
</script>
</body>

</html>